package cn.initcap.concurrency.concurrency.count;

import cn.initcap.concurrency.annoations.NotThreadSafe;
import cn.initcap.concurrency.concurrency.ThreadPoolCreatHelper;
import lombok.extern.slf4j.Slf4j;

/**
 * 多线程操作普通的读写是不安全的。
 *
 * @author initcap
 * @date Created in 2018/6/13 PM7:41.
 */
@NotThreadSafe
@Slf4j
public class NormalCount {


    /**
     * 同时并发执行的线程数
     */
    public static final int THREAD_TOTAL = 200;
    /**
     * 总请求数
     */
    private static final int CLIENT_TOTAL = 5000;
    private static int count = 0;

    public static void add() {
        count++;
    }

    public static void main(String[] args) throws Exception {
        ThreadPoolCreatHelper.threadPoolRun(CLIENT_TOTAL, THREAD_TOTAL,
                NormalCount.class, "add",
                "NormalCount");
        log.info("count:{}", count);
    }

}
